/**
 * 
 */
package com.effectivsocial.domain;

import java.io.Serializable;
import java.util.Date;


import lombok.Getter;
import lombok.Setter;

import org.springframework.data.domain.Persistable;

/**
 * @author Dhrubo
 * @param <U>
 * @param <ID>
 * 
 */


public abstract class PersistentObject<U, ID  extends Serializable> implements
		 Persistable<ID> {

	private static final long serialVersionUID = 1L;
	
	@Getter @Setter
	private ID id;
	
	@Getter @Setter
	private U assignedTo;
	
	@Getter @Setter
	private U createdBy;
	
	@Getter @Setter
	private U lastModifiedBy;
	
	@Getter @Setter
	private Date createdDate;
	
	@Getter @Setter
	private Date lastModifiedDate;
	
	@Getter @Setter
	private boolean deleted;
	
	@Getter @Setter
	private int version;
	
	@Override
	public boolean isNew() {
		// TODO Auto-generated method stub
		return false;
	}
	
	@Override
	public int hashCode() {
		if(id == null)
			return -1;
		return id.hashCode();
	}

	@SuppressWarnings("rawtypes")
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof PersistentObject)) {
			return false;
		}
		PersistentObject other = (PersistentObject) obj;
		
		System.out.println("Id == " + getId());
		
		if(getId() == null)
			return false;
		
		return getId().equals(other.getId());
	}
	
}
